/**
 * @Author: lusx
 * @Date:   21-03-2019 09:33:56
 * @Project: Govern督办
 * @Last modified by:   lusx
 * @Last modified time: 22-03-2019 05:24:18
 */
import React from "react";
import { observer, inject } from "mobx-react";
import { withRouter } from "react-router-dom";
import { ListViewPage } from "weaver-mobile-page";
import { Toast } from "weaver-mobile";
import HOCcomponent from "../hocComponent";
import openAppLink from "../../../util/add/openNewLink";
//import ComListItem from "../../governTools/comListItem/comListItem.js";
//import ComFloatTouch from "../../governTools/comFloatTouch/comFloatTouch.js";

@inject("othersStore")
@withRouter
@observer
//对比pc端,该页面为pc详情页面的剩余页面
class OthersPage extends React.Component {
  componentDidMount() {
    const {
      othersStore: { init ,searched},
      location: { search,pathname }
    } = this.props;
    const id = search.substr(search.indexOf("=") + 1);
    const key = pathname.substr(pathname.lastIndexOf("/")+1);
    if (searched === true) {
      null;
    }else {
      init({ id: id, type: "2", key: key });
    }
  }
  componentWillUnmount(){
    this.props.othersStore.clear()
  }
  render() {
    const {
      othersStore: { list }
    } = this.props;
    return (
      <div className="g-othersPage">
        {/* <ComFloatTouch icon="search" color="#ddd" onClick={this.clickFloatTouch}> */}
          <ListViewPage.Normal
            store={list}
            rowKey="docid"
            heightSpace={
              window.getThemeVars ? window.getThemeVars()["button-height"] : 47
            }
            onRowClick={this.onRowClick}
          />
        {/* </ComFloatTouch> */}
      </div>
    );
  }
  clickFloatTouch = () => {
    const {
      match: { url },
      location: { search },
      othersStore:{clickFloatTouch}
    } = this.props;
    const newUrl = url.substr(0, url.lastIndexOf("/"));
    clickFloatTouch(`${newUrl}/infoSearch`);
    this.props.history.push(`${newUrl}/infoSearch`);
  };
  onRowClick = (rowData) => {
    const {pageKey} = this.props.othersStore;
    this.onRowClickHandle(pageKey,rowData);
  }
  onRowClickHandle = (pageKey,rowData) => {
    switch(pageKey){
      case "document"://成文
        const {docid="",doctype=""} = rowData;
        //const docid = "8838",doctype = "0";
        const docidspanhref = `${docid}?requestid=${doctype}&desrequestid=${doctype}`;
        //Toast.offline("请前往pc端查看! ");
        openAppLink(docidspanhref,7);
      break;
      default: 
        ()=>{};
    }
  }
}
export default HOCcomponent(OthersPage);
